﻿/*function showitem(id,name)
{   id=id+""
	if(id.charAt(0)=="#")
	return("<span class=smallFont>&nbsp; ∟ "+name+"</span><br>");
	if(id.charAt(0)=="+")
	{
	var idx="";
	for(var i=1;i<id.length;i++)
  {
  	idx+=id.charAt(i);
  } 
	return ("<span class=smallFont>&nbsp; ∟ <a target='content' href='"+idx+"'>"+name+"</a></span><br>");
	}
	else
  //alert("item" + document.all("menutd").height);
  //document.all("menutd").height = Number(document.all("menutd").height) + 5;
    return ("<span class=smallFont onclick=prepareData('"+id+"');>&nbsp; ∟ <a target='content' href='"+id+"'>"+name+"</a></span><br>");
}
*/
function showitem(id,name)
{
    id=id+""
    if(name=="####"){
  		return "";
  	}
    if (name=="*")
    {
        return ("<span class=smallFont > <hr size=1 width=110 align=center> </span>");
    }
    if(id.charAt(0)=="#")
         return("<span class=smallFont style='padding-left:10px; width:130px;' >&nbsp;"+name+"</span><br>");
    if(id.charAt(0)=="+")
    {
         var idx="";
         for(var i=1;i<id.length;i++)
         idx+=id.charAt(i);
         return ("<span class=smallFont style='padding-left:10px; width:130px;'>&nbsp;   <a target='content' href='"+idx+"'>"+name+"</a></span><br>");
     }
     else
    return ("<span class=smallFont onclick=prepareData('"+id+"'); style='padding-left:10px; line-height:25px; width:130px;'>&nbsp;    <a target='content' href='"+id+"'>"+name+"</a></span><br>");
}

function switchoutlookBar(number)
{
	var i = outlookbar.opentitle;
	outlookbar.opentitle=number;
	var id1,id2,id1b,id2b;

	if (number!=i && outlooksmoothstat==0){

	if (number!=-1)
		{
			if (i==-1)
				{
				id2="blankdiv";
				id2b="blankdiv";}
			else{
				id2="outlookdiv"+i;
				id2b="outlookdivin"+i;
				document.all("outlooktitle"+i).otherclass="style='border-left:7px solid #7bb2d6; border-right:6px solid #7bb2d6;";
				document.all("outlooktitle"+i).style.background="url(images/cn/manv_2_bg.png)";//点击过后非当前栏目背景色
				document.all("outlooktitle"+i).style.color="996600";//点击过后非当前栏目边框色
				document.all("outlooktitle"+i).innerText="　 　"+outlookbar.titlelist[i].title;//点击后"+"
				document.all("outlooktitle"+i).style.textalign="left";
				}
			id1="outlookdiv"+number
			id1b="outlookdivin"+number
			document.all("outlooktitle"+number).otherclass="style='border-left:7px solid #7bb2d6; border-right:6px solid #7bb2d6;";
			document.all("outlooktitle"+number).style.background="url(images/cn/manv_3_bg.png)";//当前栏目背景色			document.all("outlooktitle"+number).style.color="#ffffff";//当前栏目边框色			document.all("outlooktitle"+number).innerText="　-　"+outlookbar.titlelist[number].title;//点击后"-"
			document.all("outlooktitle"+number).style.textalign="left";
			smoothout(id1,id2,id1b,id2b,0);
		}
	else
		{
			document.all("blankdiv").style.display="";
			document.all("blankdiv").sryle.height="100%";
			document.all("outlookdiv"+i).style.display="none";
			document.all("outlookdiv"+i).style.height="0%";
			document.all("outlooktitle"+i).style.border="0px solid navy";
			document.all("outlooktitle"+i).style.background="#B0CEE6";//未点击过非当前栏目背景色
			document.all("outlooktitle"+i).style.color="996600";//未点击过非当前栏目边框色
			document.all("outlooktitle"+i).style.textalign="left";
		}
	}
			
}

function smoothout(id1,id2,id1b,id2b,stat)
{
	if(stat==0){
		tempinnertext1=document.all(id1b).innerHTML;
		tempinnertext2=document.all(id2b).innerHTML;
		document.all(id1b).innerHTML="";
		document.all(id2b).innerHTML="";
		outlooksmoothstat=1;
		document.all(id1b).style.overflow="hidden";
		document.all(id2b).style.overflow="hidden";
		document.all(id1).style.height="0%";
		document.all(id1).style.display="";
		setTimeout("smoothout('"+id1+"','"+id2+"','"+id1b+"','"+id2b+"',"+outlookbar.inc+")",outlookbar.timedalay);
	}
	else
	{
		stat+=outlookbar.inc;
		if (stat>100)
			stat=100;
		document.all(id1).style.height=stat+"%";
		document.all(id2).style.height=(100-stat)+"%";
		if (stat<100) 
			setTimeout("smoothout('"+id1+"','"+id2+"','"+id1b+"','"+id2b+"',"+stat+")",outlookbar.timedalay);
		else
			{
			document.all(id1b).innerHTML=tempinnertext1;
			document.all(id2b).innerHTML=tempinnertext2;
			outlooksmoothstat=0;
			document.all(id1b).style.overflow="auto";
			document.all(id2).style.display="none";
			}
	}
}

function getOutLine()
{
	outline="<table "+outlookbar.otherclass+">";
	for (i=0;i<(outlookbar.titlelist.length);i++)
		{
  	  //alert("title" + document.all("menutd").height);
			//document.all("menutd").height = Number(document.all("menutd").height) + 6;
			outline+="<tr><td name=outlooktitle"+i+" id=outlooktitle"+i+" ";		
			if (i!=outlookbar.opentitle) 
				outline+=" nowrap align=left style='cursor:hand;background:url(images/cn/manv_2_bg.png);color:black;height:30px;' ";//初始状态的展开前景
			else
				outline+=" nowrap align=left style='cursor:hand;background:url(images/cn/manv_3_bg.png);color:black;height:30px;'";//初始状态的关闭前景
			outline+=outlookbar.titlelist[i].otherclass
			outline+=" onclick='switchoutlookBar("+i+")'><span class=smallFont>";
///////////////////////////////////
			if (i!=outlookbar.opentitle)
			outline+="　 　"+outlookbar.titlelist[i].title+"</span></td></tr>";//初始菜单标题前的+符号
			else
			outline+="　 　"+outlookbar.titlelist[i].title+"</span></td></tr>";//初始菜单标题前的-符号

/////////////////////////////////////
			outline+="<tr><td name=outlookdiv"+i+" valign=top align=left  id=outlookdiv"+i+" style='width:100%"
			if (i!=outlookbar.opentitle) 
				outline+=";display:none;height:0%;";
			else
				outline+=";display:;height:100%;";
			outline+="'><div name=outlookdivin"+i+" id=outlookdivin"+i+" style='overflow:auto;width:100%;height:100%'>";
			for (j=0;j<outlookbar.itemlist[i].length;j++)
			{
				outline+=showitem(outlookbar.itemlist[i][j].key,outlookbar.itemlist[i][j].title);			
			}
			outline+="</div></td></tr>"
		}
	outline+="<tr><td name=blankdiv valign=top align=left id=blankdiv style='height:100%;width:100%:"
	if (outlookbar.opentitle!=-1) 
				outline+=";display:none;";
			else
				outline+=";display:;";
	outline+="'><div style='overflow:auto;width:100%;height:100%'>";
	outline+="</div></td></tr>"
	
	outline+="</table>"
	return outline

}
var outstr=""

function show()
{
	var outline;
	outline="<div id=outLookBarDiv name=outLookBarDiv style='width=100%;height:100%'>"
	outline+=outlookbar.getOutLine();
	outline+="</div>"
	document.all("menutd").innerHTML = outline;

	//document.all("outLookBarDiv").innerHTML=
}

function theitem(intitle,instate,inkey)
{
	this.state=instate;
	this.otherclass=" nowrap ";
	this.key=inkey;
	this.title=intitle;
}

function addtitle(intitle)
{
	outlookbar.itemlist[outlookbar.titlelist.length]=new Array();
	outlookbar.titlelist[outlookbar.titlelist.length]=new theitem(intitle,1,0);
/*	if (outlookbar.titlelist.length != (outlookbar.starttitle+1)) 
		outlookbar.titlelist[outlookbar.titlelist.length-1].otherclass=" nowrap align=left style='cursor:hand;background-color:#336699;color:white;height:5;border:1 solid navy' ";
	else
		outlookbar.titlelist[outlookbar.titlelist.length-1].otherclass=" nowrap align=left style='cursor:hand;background-color:#C1E0FF;color:#336699;height:5;border:1 solid white' ";
*/	return(outlookbar.titlelist.length-1);
}

function additem(intitle,parentid,inkey)
{
	if (parentid>=0 && parentid<=outlookbar.titlelist.length)
	{
		outlookbar.itemlist[parentid][outlookbar.itemlist[parentid].length]=new theitem(intitle,2,inkey);
		outlookbar.itemlist[parentid][outlookbar.itemlist[parentid].length-1].otherclass=" nowrap align=left style='backgroundColor:blue;height:5' ";
		return(outlookbar.itemlist[parentid].length-1);
	}
	else
		additem=-1;
}

function outlook()
{
	this.titlelist=new Array();
	this.itemlist=new Array();
	this.divstyle="style='height:100%;width:100%;overflow:auto' align=left";
	this.otherclass="border=0 cellspacing='0' cellpadding='0' style='height:100%;width:100%'valign=middle align=left";
	this.addtitle=addtitle;
	this.additem=additem;
	this.starttitle=-1;
	this.show=show;
	this.getOutLine=getOutLine;
	this.opentitle=this.starttitle;
	this.reflesh=outreflesh;
	this.timedelay=50;
	this.inc=10;
	
}

function outreflesh()
{
	document.all("outLookBarDiv").innerHTML=outlookbar.getOutLine();
}
/*
function locatefold(foldname)
{
	for (var i=0;i<outlookbar.titlelist.length;i++)
		if(foldname==outlookbar.titlelist[i].title)
			{
				 outlookbar.starttitle=i;
				 outlookbar.opentitle=i;
			}
	
}
*/
var outlookbar=new outlook();
var tempinnertext1,tempinnertext2,outlooksmoothstat
outlooksmoothstat = 0;
